/**
 * 定义layout，配置内部routes实现子页面跳转，详见umi
 */
import { defineConfig } from 'umi';
import proxy from './proxy';
import defaultSettings from './defaultSettings';
// import routes from './routes';
const { REACT_APP_ENV } = process.env;
export default defineConfig ({
  hash: true,
  antd: {},
  dva: {
    hmr: true
  },
  history: {
    type: 'browser'
  },
  locale: {
    default: 'zh-CN',
    antd: true,
    baseNavigator: true
  },
  dynamicImport: {
    loading: '@/components/PageLoading/index',
  },
  targets: {
    ie: 11,
  },
  routes: [
    {
      path: '/',
      component: '../layouts/BlankLayout',
      routes: [
        {
          path: "/",
          component: "./home/index"
        },
        {
          path: '/user',
          component: '../layouts/UserLayout',
          routes: [
            {
              path: '/user/login',
              name: 'login',
              component: './user/login'
            }
          ]
        },
        {
          path: '/manage',
          component: '../layouts/BasicLayout',
          Routes: ['src/pages/Authorized'],
          authority: ['admin', 'user'],
          routes: [
            {
              path: '/manage',
              redirect: '/manage/home'
            },
            {
              name: 'manage.home',
              icon: 'smile',
              path: '/manage/home',
              component: './manage/index'
            },
            {
              name: 'manage.banners',
              icon: 'smile',
              path: '/manage/banners',
              component: './manage/banners/index'
            },
            {
              name: 'manage.product',
              icon: 'smile',
              path: 'manage/products',
              component: './manage/products/index'
            }
          ]
        }
      ]
    }
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    'primary-color': defaultSettings.primaryColor,
  },
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'dev'],
  manifest: {
    basePath: '/'
  },
  esbuild: {}
})